package de.jmda.mview.proj;

import java.util.HashSet;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;

import de.jmda.gui.swing.mvc.ModelBase;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class DiagramsModel extends ModelBase
{
	public final static String DEFAULT_NAME = "default diagrams model";
	
	/**
	 * project name
	 */
	@XmlAttribute(required=true)
	private String name;
	
	@XmlElementWrapper
  @XmlElements(@XmlElement(name="diagramGroup"))
	private Set<DiagramGroup> diagramGroups = new HashSet<DiagramGroup>();

	/**
	 * make JAXB happy
	 * <p>
	 * preserve this constructor for JAXB, do not call other constructors with
	 * default values
	 */
	private DiagramsModel()
	{
		super();
	}

	public DiagramsModel(String name)
	{
		this();

		this.name = name;
		
		diagramGroups.add(DiagramGroup.createDefaultDiagramGroup());
	}

	public String getName()
	{
		return name;
	}

	public Set<DiagramGroup> getDiagramGroups()
  {
  	return diagramGroups;
  }
	
	public static DiagramsModel createDefaultDiagramsModel()
	{
		return new DiagramsModel(DEFAULT_NAME);
	}
}